package com.yoshino.state;

/**
 * 发放奖品的状态
 *
 * @author yoshino
 **/
public class DispenseRaffleState implements State {

    RaffleActivity activity;

    //初始化时传入活动引用，扣除积分后改变其状态
    public DispenseRaffleState(RaffleActivity activity) {
        this.activity = activity;
    }


    @Override
    public void deduceMoney() {
        System.out.println("已经扣除积分");
    }

    // 当前状态不能抽奖
    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    // 发奖品
    @Override
    public void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜中奖了");
            //改变状态为不能抽奖
            activity.setState(activity.getNoRaffleState());
        } else {
            System.out.println("很遗憾，奖品发送完了");
            //改变状态为奖品发送完毕,不能再抽奖了
            activity.setState(activity.getDispenseOutState());
//            System.exit(0);
        }
    }
}
